// ml:run = $bin < input
#include <iostream>

using ll = long long;
ll const inf = (1ll) << 59;
ll const maxn = 200;
ll c[maxn];
ll f[maxn][maxn][maxn];
ll cost[maxn][maxn];
ll n, kk, m;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin >> n >> m >> kk;
    for (ll i = 1; i <= n; i++)
        std::cin >> c[i];
    for (ll i = 1; i <= n; i++)
        for (ll j = 1; j <= m; j++)
            std::cin >> cost[i][j];

    for (ll i = 0; i <= n; i++)
        for (ll j = 0; j <= kk; j++)
            for (ll t = 0; t <= m; t++) f[i][j][t] = inf;

    if (c[1]) f[1][1][c[1]] = 0;
    else {
        for (ll i = 1; i <= m; i++)
            f[1][1][i] = cost[1][i];
    }
    for (ll i = 2; i <= n; i++) {
        for (ll j = 1; j <= std::min(kk, i); j++) {
            if (c[i] != 0) {
                ll tmp = inf;
                if (f[i - 1][j][c[i]]) tmp = f[i - 1][j][c[i]];
                for (ll k = 1; k <= m; k++) {
                    if (k == c[i] || f[i - 1][j - 1][k] >= inf) continue;
                    tmp = std::min(tmp, f[i - 1][j - 1][k]);
                }
                f[i][j][c[i]] = tmp;
            } else {
                for (ll k = 1; k <= m; k++) {
                    ll tmp = inf;
                    if (f[i - 1][j][k]) tmp = f[i - 1][j][k] + cost[i][k];
                    for (ll t = 1; t <= m; t++) {
                        if (k == t || f[i - 1][j - 1][t] >= inf) continue;
                        tmp = std::min(tmp, f[i - 1][j - 1][t] + cost[i][k]);
                    }
                    f[i][j][k] = tmp;
                }
            }
        }
    }
    ll ans = inf;
    /* std::cout << f[1][1][2] << " " << f[2][2][1] << " " << f[3][2][1] << "\n"; */
    for (ll i = 1; i <= m; i++)
        ans = std::min(ans, f[n][kk][i]);
    if (ans >= inf)
        std::cout << "-1\n";
    else
        std::cout << ans << "\n";
}

